package com.zenkeeuk.bookerfornfc.client.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebView;

public class AboutActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle icicle) {
	    super.onCreate(icicle);

	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    
	    setContentView(R.layout.about);
	    
	    WebView webView = (WebView)findViewById(R.id.about_contents);
	    webView.loadUrl("file:///android_asset/html/about.html");
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
	    super.onCreateOptionsMenu(menu);
	    menu.add(0, Contents.HOME_ID, 0, R.string.menu_home)
	        .setIcon(R.drawable.homebtn);
	    menu.add(0, Contents.HISTORY_ID, 0, R.string.menu_history)
	        .setIcon(R.drawable.historybtn);
	    menu.add(0, Contents.SETTINGS_ID, 0, R.string.menu_settings)
	        .setIcon(R.drawable.settingbtn);
	    return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case Contents.HOME_ID: {
	        	Intent intent = new Intent(Intent.ACTION_VIEW);
		        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
		        intent.setClassName(this, HomePageActivity.class.getName());
		        startActivity(intent);
		        break;
	        }
	        case Contents.HISTORY_ID: {
		    	Intent intent = new Intent(Intent.ACTION_VIEW);
			    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
			    intent.setClassName(this, HomePageActivity.class.getName());
			    intent.putExtra(Contents.INTENT_EXTRA_RETURN_TO_TAP_KEY, 1);
			    startActivity(intent);
			    break;
		    }
	        case Contents.SETTINGS_ID: {
	        	Intent intent = new Intent(Intent.ACTION_VIEW);
			    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
			    intent.setClassName(this, HomePageActivity.class.getName());
			    intent.putExtra(Contents.INTENT_EXTRA_RETURN_TO_TAP_KEY, 2);
			    startActivity(intent);
			    break;
	        }
	    }
	    return super.onOptionsItemSelected(item);
	}
}
